from projectapp.models import file_upload_data
class filter_sql_sen(self):
    def __init__(self,type,input):
        self.type=type
        self.input=input
    def all_type(self):
        # 当搜索的值是ALL
        if self.type=='全部素材':
            filter_data = file_upload_data.objects.all()
        else:
            filter_data=file_upload_data.objects.filter(type=self.type)
        data=filter_data.exclude(Q(name__contains='3ds')
                                                  | Q(name__contains='max')
                                                  | Q(name__contains='obj')
                                                  | Q(name__contains='mtl')
                                                  | Q(name__contains='dwg')
                                                  | Q(name__contains='lwo')
                                                  | Q(name__contains='vrml')
                                                  | Q(name__contains='psd')).values('name', 'path',
                                                                                    'id')
    def search_input(self):
        if self.type == '全部素材':
            filter_data = file_upload_data.objects.filter(
            Q(title__startswith=self.input) | Q(label__startswith=self.input) | Q(name__startswith=self.input))
        else:
            filter_data = file_upload_data.objects.filter(Q(type=self.type) & (
            Q(title__startswith=self.input) | Q(label__startswith=self.input) | Q(name__startswith=self.input)))
        data=filter_data.exclude(Q(name__contains='3ds')
                                                 |Q(name__contains='max')
                                                 |Q(name__contains='obj')
                                                 |Q(name__contains='mtl')
                                                 |Q(name__contains='dwg')
                                                 |Q(name__contains='lwo')
                                                 |Q(name__contains='vrml')
                                                 |Q(name__contains='psd')).values()